package net.thetabx.ftdba.objects;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Torrents extends ArrayList<Torrent> {
	private static final long serialVersionUID = 1L;

	public Torrents() {
        super();
    }
	
	public Torrents(String html) {
		super();
		Matcher mTorrent = Pattern.compile("<a href=\"\\?section=INFOS&amp;id=(\\d+)#FTD_MENU\" title=\"([\\w\\._-]+)\">").matcher(html);
		//Matcher mTorrent = Pattern.compile("<li class=\"torrents_category (?:data_alt)?\"><a class=\"categorie cat62 year\" href=\"\\?section=TORRENTS&amp;module=&amp;parent_cat_id=1&amp;year=\\d{4}\">(\\d{4})</a></li>\\s*<li class=\"torrents_name (?:data_alt)\"><a href=\"\\?section=INFOS&amp;id=\\d+#FTD_MENU\" title=\"[\\w\\.-]+\"> ([\\w\\.-]+) </a></li>\\s*<li class=\"imdb_id_imdb_id (?:data_alt)\"><img src=\"themes/images/more_torrents(?:_disabled)?\\.gif\" alt=\"\" /></li>\\s*<li class=\"torrents_calendar (?:data_alt)\"><img src=\"themes/images/calendar(?:_disabled)?\\.gif\" alt=\"\" /></li>\\s*<li class=\"torrents_size (?:data_alt)\">([\\d\\.]+ \\wB)</li>\\s*<li class=\"torrents_seeders (?:data_alt)\">(\\d+)</li>\\s*<li class=\"torrents_leechers (?:data_alt)\">(\\d+)</li>").matcher(html);
		while(mTorrent.find()) {
			Torrent t = new Torrent();
			t.setId(mTorrent.group(1));
			t.setTitle(mTorrent.group(2));
	        //t.setYear(mTorrent.group(2));
	        //t.setSize(mTorrent.group(3));
			//t.setSeeders(mTorrent.group(4));
	        //t.setLeechers(mTorrent.group(5));
			this.add(t);
		}
	}
}
